package com.engine4cloud.tdf.supervision.controller.web;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.data.web.response.Params;
import com.engine4cloud.tdf.common.log.annotation.SysLog;
import com.engine4cloud.tdf.supervision.dto.create.RcglSignPointCreateDTO;
import com.engine4cloud.tdf.supervision.dto.query.RcglSignPointQueryDTO;
import com.engine4cloud.tdf.supervision.dto.result.RcglSignPointResultDTO;
import com.engine4cloud.tdf.supervision.service.RcglSignPointService;
import jakarta.validation.Valid;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 定点签到表
 *
 * @author wenjie
 * @date 2024-09-27 11:39:15
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/web/sign")
@Tag(description = "SignPoint", name = "定点签到表管理-web")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class RcglSignPointWebController {

    private final RcglSignPointService rcglSignPointService;

    /**
     * 分页查询
     *
     * @param page 分页对象
     * @param dto  定点签到表
     * @return R<PageInfo < RcglSignPointResultDTO>>
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page")
    public R<PageInfo<RcglSignPointResultDTO>> pageList(@ParameterObject Params page, @Valid @ParameterObject RcglSignPointQueryDTO dto) {
        return R.ok(rcglSignPointService.pageList(page, dto));
    }


    /**
     * 通过id查询定点签到表
     *
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}")
    public R<RcglSignPointResultDTO> getById(@PathVariable("id") Long id) {
        return R.ok(rcglSignPointService.getById(id));
    }

    /**
     * 新增定点签到表
     *
     * @param dto 定点签到表
     * @return R
     */
    @Operation(summary = "新增定点签到表", description = "新增定点签到表")
    @SysLog("新增定点签到表")
    @PostMapping
    public R<Boolean> create(@Valid @RequestBody RcglSignPointCreateDTO dto) {
        return R.ok(rcglSignPointService.create(dto));
    }
}